package com.example.guideapp.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;

import com.example.guideapp.fragment.Fragment1;
import com.example.guideapp.fragment.Fragment2;
import com.example.guideapp.fragment.Fragment3;

/**
 * Created by Administrator on 2017/10/16.
 */

public class MyFragmentPagerAdapter extends FragmentPagerAdapter {

    private String[] mTitles = new String[]{"节假日","祝福语","我的节日"};

    private Fragment1 fragment1 = new Fragment1();
    private Fragment2 fragment2 = new Fragment2();
    private Fragment3 fragment3 = new Fragment3();

    public MyFragmentPagerAdapter(FragmentManager fm) {
        super(fm);
    }

    @Override
    public Fragment getItem(int position) {
        if (position == 1){
            return fragment2;
        }else if (position == 2){
            return fragment3;
        }
        return fragment1;
    }

    @Override
    public int getCount() {
        return mTitles.length;
    }

    ////ViewPager与TabLayout绑定后，这里获取到PageTitle就是Tab的Text
    @Override
    public CharSequence getPageTitle(int position) {
        return mTitles[position];
    }
}
